<template>
	<view>
<!--  企业发票  -->
    <commonWin> </commonWin>
    <view class="top tac fw">
      <text>请完善</text>
      <text class="color">基本信息</text>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic">
        <text style="width: 60%">企业年开票金额 （个人银行流水、企业对公流水、商户收款码流水）可以选一个大概金额</text>
        <view class="select disp aic" style="font-weight: 700">
          <u-input
              type="digit"
              maxlength="12"
              placeholder="请输入"
              inputAlign='right'
              border='none'
              v-model="house.yearAmount"
          ></u-input>
          <text>元</text>
        </view>
      </view>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic">
        <text style="width: 60%">整体负债 （征信体现的全部负债以及信用卡已使用额度）可以选一个大概金额</text>
        <view class="select disp aic" style="font-weight: 700">
          <u-input
              type="digit"
              maxlength="12"
              placeholder="请输入"
              inputAlign='right'
              border='none'
              v-model="house.liabilities"
          ></u-input>
          <text>元</text>
        </view>
      </view>
    </view>

		<u-picker :show="show" :immediateChange="true" :columns="list" keyName="category" @confirm="sexSelect" @cancel='show=false' closeOnClickOverlay  @close='show=false'></u-picker>
		<view class="upBtn tac colorf" @click="toSee">提交</view>
	</view>
</template>

<script>
	import {getCard,setCard,upDateCard} from "../../api/information.js"
  import commonWin from "./commonWin.vue";
	export default {
		name:"informtionList",
    components: {
      commonWin,
    },
		props:{
      flag:{
        type:Boolean,
        default:()=>{return false}
      },
      pid:{
        type:String,
        default:()=>{return ''}
      },
      ui:{
        type:String,
        default:()=>{return "0"}
      },
			isThis:{
				type:Number,
				default:()=>{return ''}
			},
      listId:{
        type:String,
        default:()=>{return ''}
      }
		},
		data() {
			return {
				show:false,
				select:null,
				status:false,
				house:{
					userId: uni.getStorageSync('userInfo').id,
          liabilities: "",
          yearAmount: ""
				},
				list:[]
			};
		},
		onReady() {
			if(this.isThis==13){
				this.getMessage()
			}
		},
		methods:{
			// 获取是否填写保单资料
			getMessage(){
				getCard(this.ui).then(res => {
					if(res.data){
						this.house = res.data
						this.status = true
					}else{
						this.status = false
					}
				})
			},
			//提交
			toSee(){
				if(this.listId){
          this.house.id = this.listId
          uni.$u.toast('资料提交中...')
					upDateCard(this.house).then(res => {
						if(res.code==0){
							uni.$u.toast('保存成功')
							setTimeout(()=>{
                uni.navigateBack()
							},500)
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}else{
          uni.$u.toast('资料提交中...')
					setCard(this.house).then(res => {
						if(res.code==0){
              console.log(this.flag)
              if (this.flag){
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=&type=1&tableId=0`
                })
              }else {
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=${this.pid}&type=0&tableId=`+res.data
                })
              }
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}
			},
		}
	}
</script>

<style lang="scss">
.top{
	line-height: 80rpx;
	background-color: #eaf3ff;
}
.messageBar{
	min-height: 80rpx;
	line-height: 80rpx;
	padding: 0 30rpx;
	margin-bottom: 10rpx;
	background-color: #fff;
	.select{
		image{
			width: 20rpx;
			height: 30rpx;
			margin-left: 10rpx;
		}
	}
}
.upBtn{
	width: 80%;
	line-height: 80rpx;
	border-radius: 40rpx;
	background-color: #0055ff;
	margin: 40rpx auto 20rpx;
}
</style>